package com.app.repository.impl;

import com.app.model.main.LoginRecord;
import com.app.repository.interfaces.LoginRecordMapper;
import com.app.support.dao.MybatisDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Lichaojie on 2017/3/12. It's a beautiful day.
 */
@Repository
public class LoginRecordMapperImpl implements LoginRecordMapper {

    @Autowired
    private MybatisDao mybatisDao;

    @Override
    public int deleteByPrimaryKey(Long id){
        return mybatisDao.delete("com.app.dao.main.LoginRecordMapper",".deleteByPrimaryKey",id);
    }

    @Override
    public int insert(LoginRecord record){
        return mybatisDao.insert("com.app.dao.main.LoginRecordMapper",".insert",record);
    }

    @Override
    public int insertSelective(LoginRecord record){
        return mybatisDao.insert("com.app.dao.main.LoginRecordMapper",".insertSelective",record);
    }

    @Override
    public LoginRecord selectByPrimaryKey(Long id){
        return mybatisDao.get("com.app.dao.main.LoginRecordMapper",".selectByPrimaryKey",id);
    }

    @Override
    public int updateByPrimaryKeySelective(LoginRecord record){
        return mybatisDao.update("com.app.dao.main.LoginRecordMapper",".updateByPrimaryKeySelective",record);
    }

    @Override
    public int updateByPrimaryKey(LoginRecord record){
        return mybatisDao.update("com.app.dao.main.LoginRecordMapper",".updateByPrimaryKey",record);
    }

    @Override
    public List<LoginRecord> getIdListBetween(String time1, String time2){
        Map<String,Object> map = new HashMap<>();
        map.put("time1",time1);
        map.put("time2",time2);
        return mybatisDao.getList("com.app.dao.main.LoginRecordMapper",".getIdListBetween",map);
    }

    @Override
    public List<LoginRecord> getListByUserIdBetween(long userId, String time1, String time2){
        Map<String,Object> map = new HashMap<>();
        map.put("userId",userId);
        map.put("time1",time1);
        map.put("time2",time2);
        return mybatisDao.getList("com.app.dao.main.LoginRecordMapper",".getListByUserIdBetween",map);
    }

    @Override
    public List<LoginRecord> getListByUserId(long userId){
        return mybatisDao.getList("com.app.dao.main.LoginRecordMapper",".getListByUserId",userId);
    }
}
